var app = getApp();
Page({

  data: {
    cateid:'',
    moreData:true,
    markShow: !1,
    page:1,
    limit:50,
    rankList:[],
  },

  onLoad: function (options) {
    wx.showLoading({
      'title': '加载中'
    });
    this.onQuery(options.md5);
  },
  onQuery: function(md5) {
    let that = this;

    const db = wx.cloud.database()
    db.collection('historys')
    .aggregate()
    .match({
      md5: md5
    })
    .sort({
        score: -1
    })
    .end()
    .then(res => {
      console.log('[数据库] [查询记录] 成功: ', res)
      wx.hideLoading();
      that.setData({
        rankList:res.list,
      })
    })
  },
  onReady: function () {

  },

  onShow: function () {
    var category = wx.getStorageSync('category');
    var params = {
      uid:app.globalData.uid,
      cateid: category.id,
      page:this.data.page,
      limit:this.data.limit
    }
    // this.getRankList(params);
  },

  goBack: function () {
    wx.navigateBack({

    })
  },
  
  onShareAppMessage: function () {
    return {
      title: "开来看看我的答题成绩吧！",
      path: "pages/start/start",
      imageUrl: "http://file.xiaomutong.com.cn/9353ef0240fb00bc800956b373ee92e5.png"
    }
  },

  go_show_mark: function () {
    this.setData({
      markShow: !this.data.markShow
    });

  },

  onMyEvent: function (t) {
    console.log(this.data.saveImgUrl)
    1 == t.detail.code && this.go_show_mark(), 2 == t.detail.code && (wx.showLoading({
      title: "图片生成中"
    }), this.go_show_mark(), a.handelShowShareImg(this, this.data.saveImgUrl));
  },
})